package com.example.service.impl;

import com.example.mapper.RoleMapper;
import com.example.pojo.Role;
import com.example.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @program: personnel-management
 * @description:
 * @author: ChenZhiXiang
 * @create: 2019-07-17 09:17
 **/
@Service
@Transactional
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> roles() {
        return roleMapper.roles();
    }

    @Override
    public int addNewRole(String role, String roleZh) {
        if (!role.startsWith("ROLE_")) {
            role = "ROLE_" + role;
        }
        return roleMapper.addNewRole(role, roleZh);
    }

    @Override
    public int deleteRoleById(Long rid) {
        return roleMapper.deleteRoleById(rid);
    }
}
